#include <string.h>
#include <stdio.h>
extern long BubbleSort(long*, long);
void cBubbleSort(long* arr, long l) {
	int n, i;
	for (n=l; n>1; n=n-1){
		for (i=0; i<n-1; i=i+1){
			if (arr[i] > arr[i+1]){
				long tmp = arr[i];
				arr[i] = arr[i+1];
				arr[i+1] = tmp;
			}
		}
	} 
}
int test() {
	#define LENGTH 11
	long orig[LENGTH] = {93,44,72,55,53,42,77,25,2,-1111,9999};
	long carr[LENGTH];
	long arr[LENGTH]; 
	memcpy (carr,orig,LENGTH*sizeof(long));
	memcpy (arr,orig,LENGTH*sizeof(long));
	cBubbleSort(carr,LENGTH);
	long r = BubbleSort(arr,LENGTH);
	if (r!=777) return 0;
	int i;
	int errors=0;
	for (i=0; i<LENGTH; i++) {
		if (arr[i]!=carr[i]) {
			printf("Arrays differ on position %d: expected %ld but %ld\n",i,carr[i],arr[i]);
			errors++;
		}
	}
	if (errors!=0) {
		return 0;
	}
	return 1;
}
RET(test()==1);
